{"ast":null,"code":"import useState from \"rc-util/es/hooks/useState\";\nimport * as React from 'react';\nimport Button from '../button';\nimport { convertLegacyProps } from '../button/button';\nfunction isThenable(thing) {\n  return !!(thing && !!thing.then);\n}\nconst ActionButton = props => {\n  const clickedRef = React.useRef(false);\n  const ref = React.useRef(null);\n  const [loading, setLoading] = useState(false);\n  const {\n    close\n  } = props;\n  const onInternalClose = function () {\n    close === null || close === void 0 ? void 0 : close.apply(void 0, arguments);\n  };\n  React.useEffect(() => {\n    let timeoutId = null;\n    if (props.autoFocus) {\n      timeoutId = setTimeout(() => {\n        var _a;\n        (_a = ref.current) === null || _a === void 0 ? void 0 : _a.focus();\n      });\n    }\n    return () => {\n      if (timeoutId) {\n        clearTimeout(timeoutId);\n      }\n    };\n  }, []);\n  const handlePromiseOnOk = returnValueOfOnOk => {\n    if (!isThenable(returnValueOfOnOk)) {\n      return;\n    }\n    setLoading(true);\n    returnValueOfOnOk.then(function () {\n      setLoading(false, true);\n      onInternalClose.apply(void 0, arguments);\n      clickedRef.current = false;\n    }, e => {\n      // Emit error when catch promise reject\n      // eslint-disable-next-line no-console\n      console.error(e);\n      // See: https://github.com/ant-design/ant-design/issues/6183\n      setLoading(false, true);\n      clickedRef.current = false;\n    });\n  };\n  const onClick = e => {\n    const {\n      actionFn\n    } = props;\n    if (clickedRef.current) {\n      return;\n    }\n    clickedRef.current = true;\n    if (!actionFn) {\n      onInternalClose();\n      return;\n    }\n    let returnValueOfOnOk;\n    if (props.emitEvent) {\n      returnValueOfOnOk = actionFn(e);\n      if (props.quitOnNullishReturnValue && !isThenable(returnValueOfOnOk)) {\n        clickedRef.current = false;\n        onInternalClose(e);\n        return;\n      }\n    } else if (actionFn.length) {\n      returnValueOfOnOk = actionFn(close);\n      // https://github.com/ant-design/ant-design/issues/23358\n      clickedRef.current = false;\n    } else {\n      returnValueOfOnOk = actionFn();\n      if (!returnValueOfOnOk) {\n        onInternalClose();\n        return;\n      }\n    }\n    handlePromiseOnOk(returnValueOfOnOk);\n  };\n  const {\n    type,\n    children,\n    prefixCls,\n    buttonProps\n  } = props;\n  return /*#__PURE__*/React.createElement(Button, Object.assign({}, convertLegacyProps(type), {\n    onClick: onClick,\n    loading: loading,\n    prefixCls: prefixCls\n  }, buttonProps, {\n    ref: ref\n  }), children);\n};\nexport default ActionButton;","map":{"version":3,"names":["useState","React","Button","convertLegacyProps","isThenable","thing","then","ActionButton","props","clickedRef","useRef","ref","loading","setLoading","close","onInternalClose","apply","arguments","useEffect","timeoutId","autoFocus","setTimeout","_a","current","focus","clearTimeout","handlePromiseOnOk","returnValueOfOnOk","e","console","error","onClick","actionFn","emitEvent","quitOnNullishReturnValue","length","type","children","prefixCls","buttonProps","createElement","Object","assign"],"sources":["/data/messenger.client/node_modules/antd/es/_util/ActionButton.js"],"sourcesContent":["import useState from \"rc-util/es/hooks/useState\";\nimport * as React from 'react';\nimport Button from '../button';\nimport { convertLegacyProps } from '../button/button';\nfunction isThenable(thing) {\n  return !!(thing && !!thing.then);\n}\nconst ActionButton = props => {\n  const clickedRef = React.useRef(false);\n  const ref = React.useRef(null);\n  const [loading, setLoading] = useState(false);\n  const {\n    close\n  } = props;\n  const onInternalClose = function () {\n    close === null || close === void 0 ? void 0 : close.apply(void 0, arguments);\n  };\n  React.useEffect(() => {\n    let timeoutId = null;\n    if (props.autoFocus) {\n      timeoutId = setTimeout(() => {\n        var _a;\n        (_a = ref.current) === null || _a === void 0 ? void 0 : _a.focus();\n      });\n    }\n    return () => {\n      if (timeoutId) {\n        clearTimeout(timeoutId);\n      }\n    };\n  }, []);\n  const handlePromiseOnOk = returnValueOfOnOk => {\n    if (!isThenable(returnValueOfOnOk)) {\n      return;\n    }\n    setLoading(true);\n    returnValueOfOnOk.then(function () {\n      setLoading(false, true);\n      onInternalClose.apply(void 0, arguments);\n      clickedRef.current = false;\n    }, e => {\n      // Emit error when catch promise reject\n      // eslint-disable-next-line no-console\n      console.error(e);\n      // See: https://github.com/ant-design/ant-design/issues/6183\n      setLoading(false, true);\n      clickedRef.current = false;\n    });\n  };\n  const onClick = e => {\n    const {\n      actionFn\n    } = props;\n    if (clickedRef.current) {\n      return;\n    }\n    clickedRef.current = true;\n    if (!actionFn) {\n      onInternalClose();\n      return;\n    }\n    let returnValueOfOnOk;\n    if (props.emitEvent) {\n      returnValueOfOnOk = actionFn(e);\n      if (props.quitOnNullishReturnValue && !isThenable(returnValueOfOnOk)) {\n        clickedRef.current = false;\n        onInternalClose(e);\n        return;\n      }\n    } else if (actionFn.length) {\n      returnValueOfOnOk = actionFn(close);\n      // https://github.com/ant-design/ant-design/issues/23358\n      clickedRef.current = false;\n    } else {\n      returnValueOfOnOk = actionFn();\n      if (!returnValueOfOnOk) {\n        onInternalClose();\n        return;\n      }\n    }\n    handlePromiseOnOk(returnValueOfOnOk);\n  };\n  const {\n    type,\n    children,\n    prefixCls,\n    buttonProps\n  } = props;\n  return /*#__PURE__*/React.createElement(Button, Object.assign({}, convertLegacyProps(type), {\n    onClick: onClick,\n    loading: loading,\n    prefixCls: prefixCls\n  }, buttonProps, {\n    ref: ref\n  }), children);\n};\nexport default ActionButton;"],"mappings":"AAAA,OAAOA,QAAQ,MAAM,2BAA2B;AAChD,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,OAAOC,MAAM,MAAM,WAAW;AAC9B,SAASC,kBAAkB,QAAQ,kBAAkB;AACrD,SAASC,UAAU,CAACC,KAAK,EAAE;EACzB,OAAO,CAAC,EAAEA,KAAK,IAAI,CAAC,CAACA,KAAK,CAACC,IAAI,CAAC;AAClC;AACA,MAAMC,YAAY,GAAGC,KAAK,IAAI;EAC5B,MAAMC,UAAU,GAAGR,KAAK,CAACS,MAAM,CAAC,KAAK,CAAC;EACtC,MAAMC,GAAG,GAAGV,KAAK,CAACS,MAAM,CAAC,IAAI,CAAC;EAC9B,MAAM,CAACE,OAAO,EAAEC,UAAU,CAAC,GAAGb,QAAQ,CAAC,KAAK,CAAC;EAC7C,MAAM;IACJc;EACF,CAAC,GAAGN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